
package com.etop.learnapp.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;

import com.etop.learnapp.R;
import com.etop.learnapp.activity.ApplyActivity;
import com.etop.learnapp.adapter.Teacher_Adapter;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class Teacher_List_Fragment extends Fragment {

    ImageButton btnAddTeacher;
    public Button  btnNext2,btn_techerListBack;

    private ListView show;
    private List list = new ArrayList();
    private Teacher_Adapter myadapter;

    private View view;

    public Teacher_List_Fragment() {

    }


    public void init() {
        // 组件

        btnAddTeacher = (ImageButton)view.findViewById(R.id.btn_add);
        btnNext2=(Button)view.findViewById(R.id.btn_Next2);
        btnNext2.setOnClickListener((ApplyActivity)getActivity());
        btn_techerListBack = (Button)view.findViewById(R.id.btn_techerListBack);
        btn_techerListBack.setOnClickListener((ApplyActivity)getActivity());
        show = (ListView)view.findViewById(R.id.lv_show);
        // 添加监听器

        btnAddTeacher.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int i = list.size();
                list.add(i);
                myadapter.notifyDataSetChanged();
            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        ((ApplyActivity)getActivity()).setCurrentPage(2);
        view = inflater.inflate(R.layout.fragment_teacher__list, container, false);
        return view;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        init();
        if(list.isEmpty())
        list.add(1);

        myadapter = new Teacher_Adapter(getActivity(), list);
        show.setAdapter(myadapter);
    }
}
